package com.example.jucdemo.LockSupport;

import java.util.concurrent.locks.LockSupport;

/**
 * @Author by KoVaVo
 * @Date 2021-09-12 19:14
 * @Desc: 使用LockSupport打印:1a2b3c4d
 */
public class a1b2c3 {

    static Thread t1,t2=null;

    public static void main(String[] args) {
        
        char [] c1 = "123456".toCharArray();
        char [] c2 = "abcdef".toCharArray();

        t1 = new Thread(()->{
            for (char c : c1) {
                System.out.println(c);
                LockSupport.unpark(t2);
                LockSupport.park();
            }
        },"t1");

        t2= new Thread(()->{
            for (char c : c2) {
                LockSupport.park();
                System.out.println(c);
                LockSupport.unpark(t1);
            }

        },"t2");
        t1.start();
        t2.start();

    }
}
